package com.jy.servlet;

import com.alibaba.fastjson.JSON;
import com.jy.bean.ShoppingTrolley;
import com.jy.service.ShoppingTrolleyService;
import com.jy.service.impl.ShoppingTrolleySericelmpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;

public class cart_reviseServlet extends HttpServlet {
    private static final Logger log = LoggerFactory.getLogger(cartServlet.class);
    private ShoppingTrolleyService shoppingTrolleyService;

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String productName = request.getParameter("productName");
        String amount = request.getParameter("amount");

        shoppingTrolleyService = new ShoppingTrolleySericelmpl();

        //判断该购物车商品是否修改成功
        boolean favg = shoppingTrolleyService.updateByproductNameQuantity(productName,amount);

        String data = JSON.toJSONString(favg);

        response.setContentType("application/json");
        response.setCharacterEncoding("utf-8");
        PrintWriter out = response.getWriter();
        out.println(data);
        log.debug("data:" +data);
    }
}
